﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using SigMIS.Model;


namespace SigMIS.ViewModel.Equipment.RoadLineVMs
{
    public partial class RoadLineListVM : BasePagedListVM<RoadLine_View, RoadLineSearcher>
    {
        protected override List<GridAction> InitGridAction()
        {
            return new List<GridAction>
            {
                this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.Import, Localizer["Sys.Import"], "Equipment", dialogWidth: 800),
                //this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.Create, Localizer["Sys.Create"],"Equipment", dialogWidth: 800),
                this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.Edit, Localizer["Sys.Edit"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.Delete, Localizer["Sys.Delete"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.Details, Localizer["Sys.Details"], "Equipment", dialogWidth: 800),
                //this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.BatchEdit, Localizer["Sys.BatchEdit"], "Equipment", dialogWidth: 800),
                this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.BatchDelete, Localizer["Sys.BatchDelete"], "Equipment", dialogWidth: 800),
                //this.MakeStandardAction("RoadLine", GridActionStandardTypesEnum.ExportExcel, Localizer["Sys.Export"], "Equipment"),
            };
        }


        protected override IEnumerable<IGridColumn<RoadLine_View>> InitGridHeader()
        {
            return new List<GridColumn<RoadLine_View>>{                                
                this.MakeGridHeader(x => x.RoadLineName),
                this.MakeGridHeader(x => x.POICode),
                this.MakeGridHeader(x => x.POIName),
                this.MakeGridHeader(x => x.POIAttribute),
                this.MakeGridHeader(x => x.WorkMode),
                this.MakeGridHeader(x => x.Longitude),
                this.MakeGridHeader(x => x.Latitude),
                this.MakeGridHeader(x => x.Mileage),
                this.MakeGridHeader(x => x.AtBureauName),
                this.MakeGridHeader(x => x.AtBureauCode),
                this.MakeGridHeader(x => x.AtRoadLineName),
                this.MakeGridHeader(x => x.AtRoadLineCode),
                this.MakeGridHeader(x => x.AtSectionName),
                this.MakeGridHeader(x => x.AtDispatchingName),
                this.MakeGridHeader(x => x.StationName),
                this.MakeGridHeader(x => x.StationCode),
                this.MakeGridHeader(x => x.StationPhone),
                this.MakeGridHeader(x => x.Meandering),
                this.MakeGridHeader(x => x.Altitude),
                this.MakeGridHeader(x => x.IP),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<RoadLine_View> GetSearchQuery()
        {
            var query = DC.Set<RoadLine>()
                .CheckEqual(Searcher.RoadLineName, x => x.RoadLineName)
                .CheckEqual(Searcher.Longitude, x=>x.Longitude)
                .CheckEqual(Searcher.Latitude, x => x.Latitude)
                .CheckEqual(Searcher.Mileage, x=>x.Mileage)
                .CheckContain(Searcher.AtBureauName, x=>x.AtBureauName)
                .CheckContain(Searcher.AtRoadLineName, x=>x.AtRoadLineName)
                .CheckContain(Searcher.AtDispatchingName, x=>x.AtDispatchingName)
                .CheckContain(Searcher.StationName, x=>x.StationName)
                .Select(x => new RoadLine_View
                {
				    ID = x.ID,
                    RoadLineName = x.RoadLineName,
                    POICode = x.POICode,
                    POIName = x.POIName,
                    POIAttribute = x.POIAttribute,
                    WorkMode = x.WorkMode,
                    Longitude = x.Longitude,
                    Latitude = x.Latitude,
                    Mileage = x.Mileage,
                    AtBureauName = x.AtBureauName,
                    AtBureauCode = x.AtBureauCode,
                    AtRoadLineName = x.AtRoadLineName,
                    AtRoadLineCode = x.AtRoadLineCode,
                    AtSectionName = x.AtSectionName,
                    AtDispatchingName = x.AtDispatchingName,
                    StationName = x.StationName,
                    StationCode = x.StationCode,
                    StationPhone = x.StationPhone,
                    Meandering = x.Meandering,
                    Altitude = x.Altitude,
                    IP = x.IP,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class RoadLine_View : RoadLine{

    }
}
